/*
 *
 * @ProjectName:    my_umi_app
 * @Package:
 * @ClassName:      tap_api
 * @Description:    TypeScript文件
 * @Author:         SuPeiSen
 * @CreateDate:     2021/1/21 2:24 下午
 * @UpdateDate:     2021/1/21 2:24 下午
 * @UpdateRemark:   更新说明：
 * @Version:        1.0
 */

// 添加分类
import { AxiosParam, Requests } from '@/utils/requests';
import { ApiPath } from '@/config/api_config';
import { TagItemType, TagListType } from '@/type/tag';

export const addTagApi = async (
  postParam: any,
  finallyCallBack: () => void,
) => {
  const model = await Requests.defaults.http('post', ApiPath.addTag, {
    postData: postParam,
    callBack: {
      finally: finallyCallBack,
    },
  });
  return model.success;
};

// 获取Tag分页
export const getTagListApi = async (param: AxiosParam) => {
  return await Requests.defaults.http<TagListType>(
    'get',
    ApiPath.getAllTagByPage,
    {
      getData: param,
    },
  );
};

// 获取所以的Tag
export const getAllTagApi = async (finallyCallBack: () => void) => {
  return await Requests.defaults.http<Array<TagItemType>>(
    'get',
    ApiPath.getTags,
    {
      callBack: {
        finally: finallyCallBack,
      },
    },
  );
};

export const updateTagApi = async (
  postParam: any,
  finallyCallBack: () => void,
) => {
  const model = await Requests.defaults.http('put', ApiPath.updateTag, {
    postData: postParam,
    callBack: {
      finally: finallyCallBack,
    },
  });
  return model.success;
};
